/*
 * 文件名:GzipFilter.java
 * 创建时间:2010-03-10
 * 版本:1.0
 * 版权所有:杨涛
 */
package com.yangtao.framework.web.filter;

import javax.servlet.*;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 为一个gzip压缩的文件提供浏览器解析gzip的头消息
 *
 * @author 杨涛
 * @version 1.0
 */
public class GzipFilter implements Filter {

	@Override
	public void destroy() {
	}

	@Override
	public void doFilter(ServletRequest request, ServletResponse response,
	                     FilterChain chain) throws IOException, ServletException {
		if (response instanceof HttpServletResponse) {
			((HttpServletResponse) response).setHeader("Content-Encoding",
					"gzip");
		}
		chain.doFilter(request, response);
	}

	@Override
	public void init(FilterConfig filterConfig) throws ServletException {
	}

}
